package com.edu.dk.security.impl;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletResponseWrapper;

import com.edu.dk.security.WebContext;

public class AbstractResponseWrapper extends HttpServletResponseWrapper {

	private WebContext context;

	/**
	 * 
	 * 创建一个response wrapper。
	 * 
	 * @param context
	 *            request context
	 * 
	 * @param response
	 * 
	 */
	public AbstractResponseWrapper(WebContext context, HttpServletResponse response) {
		super(response);
		this.context = context;

	}

	/**
	 * 
	 * 取得当前request所处的servlet context环境。
	 *
	 * 
	 * @return <code>ServletContext</code>对象
	 * 
	 */
	public ServletContext getServletContext() {
		return getWebContext().getServletContext();
	}

	/**
	 * 
	 * 取得支持它们的<code>getWebContext</code>。
	 *
	 * @return <code>getWebContext</code>实例
	 * 
	 */
	public WebContext getWebContext() {
		return context;
	}

	/**
	 * 
	 * 取得字符串表示。
	 *
	 * 
	 * @return 字符串表示
	 * 
	 */
	public String toString() {
		return "Http response within request context: " + getWebContext().toString();
	}

}
